// Simple device detection utilities

export function getDeviceType() {
	const userAgent = navigator.userAgent || ''
	const maxTouchPoints = navigator.maxTouchPoints || 0
	const isIPad = /iPad/i.test(userAgent) || (navigator.platform === 'MacIntel' && maxTouchPoints > 1)
	const isAndroid = /Android/i.test(userAgent)
	const isAndroidTablet = isAndroid && !/Mobile/i.test(userAgent)
	const isTabletUA = /Tablet|PlayBook|Silk/i.test(userAgent) || isIPad || isAndroidTablet
	const isMobileUA = /Mobi|iPhone|iPod|Windows Phone|Phone/i.test(userAgent) || (/Android/i.test(userAgent) && /Mobile/i.test(userAgent))

	const width = Math.min(window.screen.width, window.innerWidth)
	if (isMobileUA || width <= 768) return 'mobile'
	if (isTabletUA || (width > 768 && width <= 1200)) return 'tablet'
	return 'pc'
}

export function isMobile() {
	return getDeviceType() === 'mobile'
}

export function isTablet() {
	return getDeviceType() === 'tablet'
}

export function isPc() {
	return getDeviceType() === 'pc'
}

